home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 1.toast / pc / sample code / devices and hardware / adb / controlkeypatch / controlkeypatch.a < prev    next >
Encoding:
Text File  |  2000-06-23  |  2.6 KB  |  118 lines

  1. ;;    File:        ControlKeyPatch.a
  2. ;;    
  3. ;;    Description: 
  4. ;;             routines for patching the ADB manager to simulate the control
  5. ;;            key being held down.  This file contains the 68000 code for
  6. ;;            the patch resource.
  7. ;;
  8. ;;    Author:    John Montbriand
  9. ;;
  10. ;;    Copyright: 
  11. ;;            Copyright © 1999 by Apple Computer, Inc.
  12. ;;            All rights reserved worldwide.
  13. ;;    
  14. ;;    Disclaimer:
  15. ;;            You may incorporate this sample code into your applications without
  16. ;;            restriction, though the sample code has been provided "AS IS" and the
  17. ;;            responsibility for its operation is 100% yours.  However, what you are
  18. ;;            not permitted to do is to redistribute the source as "DSC Sample Code"
  19. ;;            after having made changes. If you're going to re-distribute the source,
  20. ;;            we require that you make it clear in the source that the code was
  21. ;;            descended from Apple Sample Code, but that you've made changes.
  22. ;;    
  23. ;;    Change History (most recent first):
  24. ;;            27/8/99 created by John Montbriand
  25.  
  26.     case on
  27.     include 'Types.a'
  28.     
  29. ADBPatchResource    main
  30.  
  31.     bra.s    ADBPatch(PC)
  32.     bra.s    SetDown(PC)
  33.     bra.s    SetUp(PC)
  34.  
  35. command        EQU        0    ; key down command
  36. downflag        EQU        4    ; flag for tracking key
  37. originaljump    EQU        8    ; original service routine
  38. originaldata    EQU        12    ; original service routine's data
  39.  
  40. controldown:
  41.     dc.l        $0236FF00
  42.     
  43. controlup:
  44.     dc.l        $02B6FF00
  45.  
  46. SetDown:
  47.     movea.l        4(SP), A2
  48.     cmpi.l        #1, downflag(A2)    ;; test to see if the key is already down
  49.     beq.s        @1
  50.             ;; set the down flag to true
  51.         move.l        #1, downflag(A2)
  52.             ;; jump to the original service routine
  53.         move.l        command(A2), D0
  54.         lea            controldown(PC), A0
  55.         movea.l        #0, A1
  56.         move.l        originaljump(A2), -(SP)
  57.         movea.l        originaldata(A2), A2
  58.         rts
  59.         
  60.     @1:
  61.     rts
  62.  
  63. SetUp:
  64.     movea.l        4(SP), A2
  65.     cmpi.l        #0, downflag(A2)    ;; test to see if the key is already up
  66.     beq.s        @1
  67.             ;; set the down flag to false
  68.         move.l        #0, downflag(A2)
  69.             ;; jump to the original service routine
  70.         move.l        command(A2), D0
  71.         lea            controlup(PC), A0
  72.         movea.l        #0, A1
  73.         move.l        originaljump(A2), -(SP)
  74.         movea.l        originaldata(A2), A2
  75.         rts
  76.         
  77.     @1:
  78.     rts
  79.  
  80. ADBPatch:
  81.         ;; R0?
  82.     btst            #0, D0
  83.     bne.s        @1
  84.     btst            #1, D0
  85.     bne.s        @1
  86.         ;; talk?
  87.     btst            #2, D0
  88.     beq.s        @1
  89.     btst            #3, D0
  90.     beq.s        @1
  91.         ;; test to see if the key is locked down
  92.     cmpi.l        #1, downflag(A2)    ;; test to see if the key is down
  93.     bne.s        @1
  94.             ;; block key downs
  95.         cmpi.b        #$02, 0(A0)
  96.         bne.s        @2
  97.         cmpi.b        #$36, 1(A0)
  98.         bne.s        @2
  99.         cmpi.b        #$FF, 2(A0)
  100.         bne.s        @2
  101.             rts
  102.         @2:    ;; block key ups
  103.         cmpi.b        #$02, 0(A0)
  104.         bne.s        @1
  105.         cmpi.b        #$B6, 1(A0)
  106.         bne.s        @1
  107.         cmpi.b        #$FF, 2(A0)
  108.         bne.s        @1
  109.             rts
  110.     @1:    ;; jump through to the original routine
  111.     move.l        originaljump(A2), -(SP)
  112.     movea.l        originaldata(A2), A2
  113.     rts
  114.  
  115.     endmain
  116.  
  117.     end
  118.